package view.user;


import model.booking.Booking;
import model.user.User;
import view.MyAbstractTableModel;

import java.util.ArrayList;

public class ReservationHistoryModel extends MyAbstractTableModel<Booking> {
    public ReservationHistoryModel(User user) {
        //初始化数据
        datas = new ArrayList<Booking>();
        datas = Booking.getBookingHostryList(user);//修改的地方
        //定义表头
        this.columnNames = new String[]{"入住人", "入住人ID", "入住时间", "退房时间", "房间类型", "价格", "状态"};
    }
    @Override
    protected Object getProperty(Object obj, int columnIndex) {
        Object result = "";
        switch (columnIndex) {
            case 0:
                return ((Booking) obj).getCheckInPerson();
            case 1:
                return ((Booking) obj).getCheckInPersonId();
            case 2:
                return ((Booking) obj).getCheckInTime();
            case 3:
                return ((Booking) obj).getCheckOutTime();
            case 4:
                return ((Booking) obj).getRoomTypes();
            case 5:
                return ((Booking) obj).getPrice();
            case 6:
                return ((Booking) obj).getStatus();
        }
        return result;
    }
}
